package com.jz.community.moduleshoppingguide.neighbor.presenter;

import com.jz.community.basecomm.mvp.BaseLifeCyclePresent;
import com.jz.community.basecomm.net.rxandroid.OnLoadListener;
import com.jz.community.moduleshoppingguide.neighbor.bean.BlogsListBean;
import com.jz.community.moduleshoppingguide.neighbor.bean.CircleMessageBean;
import com.jz.community.moduleshoppingguide.neighbor.model.NeighborModel;
import com.jz.community.moduleshoppingguide.neighbor.model.NeighborModelImp;
import com.jz.community.moduleshoppingguide.neighbor.ui.NeighborCircleView;

public class NeighborCirclePresenter extends BaseLifeCyclePresent<NeighborCircleView.View> implements NeighborCircleView.Presenter {

    private NeighborModel neighborModel;
    private NeighborCircleView.View view;


    public NeighborCirclePresenter(NeighborCircleView.View view) {
        this.view = view;
        this.neighborModel = new NeighborModelImp(view.getContext());
    }


    @Override
    public void circleDynamic(String circle_id, int page, int size, int type) {
        neighborModel.circleDynamic(circle_id, page, size, new OnLoadListener<BlogsListBean>() {
            @Override
            public void onSuccess(BlogsListBean blogsListBean) {
                view.showCircleDynamic(blogsListBean, type);
            }

            @Override
            public void onFail(String msg, int code) {
                view.showError(msg);
            }
        });
    }

    @Override
    public void initNeighborMsg(String circleId, String lat, String lon) {
        neighborModel.initNeighborMsg(circleId, lat, lon, new OnLoadListener<CircleMessageBean>() {
            @Override
            public void onSuccess(CircleMessageBean circleMessageBean) {
                view.setNeighborMsgData(circleMessageBean);
            }

            @Override
            public void onFail(String msg, int code) {
                view.showError(msg);
            }
        });

    }
}
